import re
import urllib

def getHtml(url):
	page = urllib.urlopen(url)
	html = page.read()
	return html

def getImg(html):
	reg = r'http://(.+?\.jpg)"'
	imgre = re.compile(reg)
	imglist = re.findall(imgre, html)
	i = 1	
	for imgurl in imglist:
		source = index + imgurl
		print(source)
		try:
			urllib.urlretrieve(source,'%s.jpg' %x)
		except:
			print("ERROR: " + source)
			continue
		finally:
			i+=1

page = "http://image.baidu.com/search/index?tn=baiduimage&ct=201326592&lm=-1&cl=2&word=%CB%AE%D2%B0%B3%AF%D1%F4&t=3&ie=gbk"
index = "http://"
html = getHtml(page)
print getImg(html)
